home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE11 / GETICON / PHONE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  20KB  |  616 lines

  1. #include <windows.h> 
  2. #include <windowsx.h> 
  3. #include "phone.h" 
  4. #include "tapi.h"
  5.  
  6. #define BUFSIZE 256
  7. #define APIHIVERSION     0x00010028    /* 1.40 */
  8. #define APILOWVERSION    0x00010000    /* 1.0 */
  9. #define EXTHIVERSION     0x00010005    /* 1.5 */
  10. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  11. #define MAX_PHONE        2
  12. #define OWNER            0
  13. #define MONITOR        1
  14.  
  15. LPCTSTR lpszAppName = "phoneGetIcon";
  16. LPCTSTR lpszTitle   = "phoneGetIcon"; 
  17.  
  18.  
  19. #if defined (WIN32)
  20.     #define IS_WIN32 TRUE
  21. #else
  22.     #define IS_WIN32 FALSE
  23. #endif
  24.  
  25. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  26. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  27. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  28.  
  29. HINSTANCE hInst;   // current instance
  30. HWND hWnd;         // parent window handle
  31. HWND hListWnd;     // listbox
  32. HDC  hdc;
  33. TEXTMETRIC  tm ;
  34.  
  35. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  36.  
  37.  
  38. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  39.                       LPTSTR lpCmdLine, int nCmdShow)
  40. {
  41.    MSG      msg;
  42.    WNDCLASS wc;
  43.  
  44.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  45.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  46.    wc.cbClsExtra    = 0;                      
  47.    wc.cbWndExtra    = 0;                      
  48.    wc.hInstance     = hInstance;              
  49.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  50.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  51.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  52.    wc.lpszMenuName  = lpszAppName;              
  53.    wc.lpszClassName = lpszAppName;              
  54.  
  55.    if ( IS_WIN95 )
  56.    {
  57.       if ( !RegisterWin95( &wc ) )
  58.          return( FALSE );
  59.    }
  60.    else if ( !RegisterClass( &wc ) )
  61.       return( FALSE );
  62.  
  63.    hInst = hInstance; 
  64.  
  65.    hWnd = CreateWindow( lpszAppName, 
  66.                         lpszTitle,    
  67.                         WS_OVERLAPPEDWINDOW, 
  68.                         CW_USEDEFAULT, 0, 
  69.                         CW_USEDEFAULT, 0,  
  70.                         NULL,              
  71.                         NULL,              
  72.                         hInstance,         
  73.                         NULL               
  74.                       );
  75.  
  76.    if ( !hWnd ) 
  77.       return( FALSE );
  78.  
  79.    ShowWindow( hWnd, nCmdShow ); 
  80.    UpdateWindow( hWnd );         
  81.  
  82.    while( GetMessage( &msg, NULL, 0, 0) )   
  83.    {
  84.       TranslateMessage( &msg ); 
  85.       DispatchMessage( &msg );  
  86.    }
  87.  
  88.    return( msg.wParam ); 
  89. }
  90.  
  91.  
  92. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  93. {
  94.     WNDCLASSEX wcex;
  95.  
  96.    wcex.style         = lpwc->style;
  97.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  98.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  99.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  100.    wcex.hInstance     = lpwc->hInstance;
  101.    wcex.hIcon         = lpwc->hIcon;
  102.    wcex.hCursor       = lpwc->hCursor;
  103.    wcex.hbrBackground = lpwc->hbrBackground;
  104.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  105.    wcex.lpszClassName = lpwc->lpszClassName;
  106.  
  107.    // Added elements for Windows 95.
  108.    //...............................
  109.    wcex.cbSize = sizeof(WNDCLASSEX);
  110.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  111.                             IMAGE_ICON, 16, 16,
  112.                             LR_DEFAULTCOLOR );
  113.             
  114.    return RegisterClassEx( &wcex );
  115. }
  116.  
  117. typedef struct tagMYINFO    // general application information
  118. {
  119.    HPHONEAPP phoneApp;      // instance handle TAPI gives back to us                                                                              through phoneInitialize()
  120.    DWORD dwNumDevices;     // number of available devices
  121.    DWORD dwAPIVersion;     // API version the phone supports
  122.     DWORD dwExtVersion;        // extended version
  123. } MYINFO;
  124.  
  125. typedef struct tagPHONEINFO  // information on an open phone
  126. {
  127.    HPHONE     hPhone;           // handle to the phone as returned by phoneOpen 
  128.     DWORD      dwDeviceID;            // device ID of the phone device
  129.     DWORD        dwRequestID;
  130.     char       szPhoneName[128]; // the phone's name 
  131. }PHONEINFO;
  132.  
  133. MYINFO myInfo;          //instance of MYINFO structure
  134. PHONEINFO myPhoneInfo[MAX_PHONE];  //instance of myPhoneInfo structure
  135.  
  136. LONG lRet;        //return code
  137. char buf[BUFSIZE];    // buffer for debug message
  138. char DataBuf[BUFSIZE]; //get/set data buffer;
  139.  
  140. DWORD i;
  141. DWORD dwHookSwitchDevs;
  142. DWORD dwLampMode;
  143. DWORD dwRingMode;
  144. DWORD dwRingVolume;
  145. DWORD dwHookSwitchVolume;
  146. DWORD dwPhoneStates;
  147. DWORD dwButtonModes;
  148. DWORD dwButtonStates;
  149. DWORD dwGain;
  150. HICON hIcon;
  151.  
  152. LONG lRet;
  153. char buf[BUFSIZE];
  154.  
  155. PHONECAPS*             pPhoneCaps;
  156. PHONEBUTTONINFO*  pButtonInfo;
  157. VARSTRING*            pVarString;
  158. PHONESTATUS*        pPhoneStatus;
  159. PHONEEXTENSIONID    ext_id;                                             
  160.  
  161.  
  162. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  163. {
  164.    switch( uMsg )
  165.    {
  166.       case WM_COMMAND :
  167.          switch( LOWORD( wParam ) )
  168.          {
  169.             case IDM_RUN :
  170.                lRet = phoneGetIcon(myPhoneInfo[OWNER].dwDeviceID,
  171.                                     "tapi/phone", &hIcon);
  172.                     if (lRet == 0)
  173.                    {
  174.                    hdc = GetDC (hWnd);
  175.                   DrawIcon(hdc, 2, 2, hIcon);
  176.                   ReleaseDC(hWnd, hdc);
  177.                   wsprintf( buf,"phoneGetIcon succeeded");
  178.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  179.                   }
  180.                      else 
  181.                    {
  182.                        wsprintf( buf,"phoneGetIcon failed, err=x%lx", lRet);
  183.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  184.                        phoneError(lRet);
  185.                    }    
  186.                       break;
  187.             
  188.             case IDM_EXIT :
  189.                for (i = 0; i < myInfo.dwNumDevices; i++)
  190.                     phoneClose(myPhoneInfo[i].hPhone);
  191.                 
  192.                    phoneShutdown(myInfo.phoneApp);
  193.                DestroyWindow( hWnd );
  194.                break;
  195.          
  196.             case IDM_ABOUT :
  197.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  198.                break;
  199.          }
  200.                 
  201.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  202.  
  203.       
  204.        case WM_CREATE :
  205.  
  206.           hdc = GetDC (hWnd) ;
  207.           GetTextMetrics (hdc, &tm) ;
  208.           ReleaseDC (hWnd, hdc) ;
  209.  
  210.           hListWnd = CreateWindowEx( 0, "listbox", 
  211.                         " ",    
  212.                         WS_CHILD | WS_VISIBLE,  
  213.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  214.                         tm.tmAveCharWidth * 16 +
  215.                                    GetSystemMetrics (SM_CXVSCROLL), 
  216.                         tm.tmHeight * 5,  
  217.                         hWnd,              
  218.                         NULL,              
  219.                         hInst,         
  220.                         NULL               
  221.                         );
  222.       
  223.              //phoneInitialize
  224.                //...............................................
  225.             lRet = phoneInitialize(&myInfo.phoneApp, hInst, phoneCallback, lpszAppName, &myInfo.dwNumDevices);
  226.             if (lRet == 0) 
  227.             {
  228.                 
  229.                wsprintf(buf, "phoneInitialize succeeded!");
  230.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  231.             }
  232.                
  233.                else 
  234.                {
  235.                    wsprintf( buf,"phoneInitialize failed, err=x%lx",lRet);
  236.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  237.                     phoneError(lRet);
  238.                     break;
  239.             }                    
  240.                
  241.             //phoneNegotiateAPIVersion
  242.                   //...............................................
  243.             lRet = phoneNegotiateAPIVersion(myInfo.phoneApp, 0, APILOWVERSION, APIHIVERSION, 
  244.                                                     &myInfo.dwAPIVersion, &ext_id);
  245.             if (lRet == 0)                        
  246.             {
  247.                wsprintf(buf, "phoneNegotiateAPIVersion succeeded!");
  248.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  249.             }
  250.                   else 
  251.                   {
  252.                    wsprintf(buf, "phoneNegotiateAPIVersion failed, err=x%lx", lRet);
  253.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  254.                     phoneError(lRet);
  255.                     phoneShutdown(myInfo.phoneApp);
  256.                break;
  257.              }
  258.  
  259.                //phoneNegotiateExtVersion
  260.                //...............................................
  261.             lRet = phoneNegotiateExtVersion(myInfo.phoneApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  262.                                                 EXTHIVERSION, &myInfo.dwExtVersion);
  263.             if (lRet == 0)                        
  264.             {
  265.                     wsprintf(buf, "phoneNegotiateExtVersion succeeded!");
  266.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  267.               }
  268.                   else 
  269.                {
  270.                     wsprintf(buf, "phoneNegotiateExtVersion failed, err=x%lx", lRet);
  271.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  272.                       phoneError(lRet);
  273.                }
  274.  
  275.             //phoneOpen
  276.                //................................................................
  277.                for (i = 0; i < myInfo.dwNumDevices; i++)
  278.                {
  279.                    if ( i == 0)
  280.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  281.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_OWNER);
  282.                    else
  283.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  284.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_MONITOR);
  285.                    
  286.                    if (lRet == 0)
  287.                    {
  288.                      wsprintf(buf, "phoneOpen succeeded!");
  289.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  290.                   pPhoneCaps = (PHONECAPS *) calloc (1, sizeof(PHONECAPS)+1000);
  291.                       pPhoneCaps->dwTotalSize = sizeof(PHONECAPS) + 1000;
  292.                          
  293.                       phoneGetDevCaps(myInfo.phoneApp,i,
  294.                       myInfo.dwAPIVersion, myInfo.dwExtVersion, pPhoneCaps);
  295.                       strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwProviderInfoOffset));
  296.                   strcat( buf, " is the phone providor's name." );
  297.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  298.                   strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwPhoneNameOffset));
  299.                      
  300.                   if (i == 0)
  301.                   {
  302.                      strcat( buf, " is the phone's name opened with OWNER privilege." );
  303.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  304.                   }
  305.                   else
  306.                   {
  307.                      strcat( buf, " is the phone's name opened with MONITOR privilege." );
  308.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  309.                   }
  310.                }
  311.                    else 
  312.                    {
  313.                        wsprintf( buf,"phoneOpen failed, err=x%lx", lRet);
  314.                        phoneError(lRet);
  315.                       break;
  316.                }
  317.                   } 
  318.  
  319.             break;
  320.       
  321.       case WM_SIZE:
  322.           MoveWindow(hListWnd, 0, 40, LOWORD(lParam), HIWORD(lParam), TRUE);
  323.          break;
  324.  
  325.       case WM_DESTROY :
  326.          PostQuitMessage(0);
  327.          break;
  328.             
  329.       default :
  330.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  331.    }
  332.  
  333.    return( 0L );
  334. }
  335.  
  336.  
  337.  
  338.  
  339. /****************************************************************************
  340.     FUNCTION: phoneCallback
  341.     PURPOSE:  callback function handles phone events
  342. ****************************************************************************/
  343. LRESULT CALLBACK phoneCallback (DWORD  dwDevice, DWORD dwMsg,
  344.                                 DWORD dwCallbackInst, DWORD dwParam1,
  345.                                 DWORD dwParam2,DWORD dwParam3)
  346. {
  347.     
  348.     switch (dwMsg)
  349.     {
  350.         case PHONE_REPLY:
  351.             if (dwParam1 == myPhoneInfo[OWNER].dwRequestID) 
  352.                    if (dwParam2 != 0)
  353.                 {
  354.                        wsprintf( buf,"Function failed, err=x%lx", lRet);
  355.                        phoneError(lRet);
  356.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  357.                    }
  358.             break;       
  359.  
  360.         case PHONE_STATE:
  361.         
  362.             if (dwParam1 == PHONESTATE_RINGMODE)
  363.             {
  364.                 lRet = phoneGetRing(myPhoneInfo[OWNER].hPhone, &dwRingMode, &dwRingVolume);
  365.                 if (lRet == 0)
  366.                {
  367.                 wsprintf(buf, "phoneGetRing succeeded!");
  368.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  369.                if (dwRingMode == 0)
  370.                     {
  371.                         wsprintf(buf, "The phone device is currently not ringing.");
  372.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  373.                }
  374.                     else
  375.                     {
  376.                         wsprintf(buf, "The phone is ringing with a Ring Mode pattern of x%lx", dwRingMode);
  377.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  378.                    wsprintf(buf, "The phnes's Ring Volume is x%lx", dwRingVolume);
  379.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  380.                     }
  381.                }
  382.                  else 
  383.                {
  384.                     wsprintf( buf,"phoneGetRing failed, err=x%lx", lRet);
  385.                    phoneError(lRet);
  386.                }        
  387.               
  388.               break;
  389.               }
  390.             
  391.  
  392.             if (dwParam1 == PHONESTATE_SPEAKERHOOKSWITCH)
  393.             {   
  394.                 lRet = phoneGetHookSwitch(myPhoneInfo[OWNER].hPhone, &dwHookSwitchDevs);
  395.                 if (lRet == 0)
  396.                {
  397.                wsprintf(buf, "phoneGetHookSwitch succeeded!");
  398.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  399.                
  400.                if (dwHookSwitchDevs & PHONEHOOKSWITCHDEV_SPEAKER)
  401.                     {
  402.                         wsprintf(buf, "The phone's HookSwitch Speaker is offhook!");
  403.                        SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  404.                     }
  405.                     else
  406.                     {
  407.                    wsprintf(buf, "The phone's HookSwitch Speaker is onhook!");
  408.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  409.                     }
  410.  
  411.               }
  412.                  else 
  413.                {
  414.                       wsprintf( buf,"phoneGetHookSwitch failed, err=x%lx", lRet);
  415.                    phoneError(lRet);
  416.                }    
  417.             break;                
  418.             }
  419.  
  420.             if (dwParam1 == PHONESTATE_SPEAKERVOLUME)
  421.             {   
  422.                 lRet = phoneGetVolume(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwHookSwitchVolume);
  423.                if (lRet == 0)
  424.                {
  425.                 wsprintf(buf, "phoneGetVolume succeeded!");
  426.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  427.                wsprintf(buf, "The current volume for the Speaker Hookswitch is x%lx", dwHookSwitchVolume);
  428.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  429.                }
  430.                  else 
  431.                {
  432.                     wsprintf( buf,"phoneGetVolume failed, err=x%lx", lRet);
  433.                    phoneError(lRet);
  434.                }    
  435.             break;                
  436.             }
  437.  
  438.             if (dwParam1 == PHONESTATE_SPEAKERGAIN)
  439.             {   
  440.                 lRet = phoneGetGain(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwGain);
  441.                 if (lRet == 0)
  442.                {
  443.                   wsprintf(buf, "phoneGetGain succeeded!");
  444.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  445.                     wsprintf(buf, "The current Gain is x%lx", dwGain);
  446.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  447.                }
  448.                  else 
  449.                {
  450.                       wsprintf( buf,"phoneGetGain failed, err=x%lx", lRet);
  451.                     phoneError(lRet);
  452.                }
  453.             break;                
  454.             }
  455.             
  456.             if (dwParam1 == PHONESTATE_DISPLAY)
  457.             {   
  458.                 pVarString = (VARSTRING *) calloc (1, sizeof(VARSTRING)+1000);
  459.                 pVarString->dwTotalSize = sizeof(VARSTRING) + 1000;
  460.                 lRet = phoneGetDisplay(myPhoneInfo[OWNER].hPhone, pVarString);
  461.                 if (lRet == 0)
  462.                {
  463.                   wsprintf(buf, "phoneGetDisplay succeeded!");
  464.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  465.                strcpy(buf, lpszTitle);
  466.                //strcpy(buf, ((LPSTR)(pVarString)+pVarString->dwStringOffset));
  467.                strcat( buf, " is the current phone display." );
  468.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  469.                }
  470.                  else 
  471.                {
  472.                    wsprintf( buf,"phoneGetDisplay failed, err=x%lx", lRet);
  473.                   phoneError(lRet);
  474.                }    
  475.                     
  476.                 free (pVarString);
  477.                 break;
  478.               }
  479.    }
  480.    return (TRUE);
  481.  
  482.  
  483. /****************************************************************************
  484.     FUNCTION: phoneError
  485.     PURPOSE:  phone error messages
  486. ****************************************************************************/
  487. void phoneError (LONG lrc)
  488. {
  489.  switch (lrc) {
  490.     case PHONEERR_INVALAPPHANDLE:
  491.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  492.        break;
  493.     case PHONEERR_BADDEVICEID:
  494.        MessageBox (hWnd,"The specified phone device ID is out of range.", "", 
  495.                    MB_OK);
  496.        break;
  497.     case PHONEERR_INCOMPATIBLEAPIVERSION:
  498.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  499.        break;
  500.     
  501.     case PHONEERR_INVALBUTTONLAMPID:
  502.        MessageBox (hWnd, "Invalid Button Lamp ID.", "", MB_OK);
  503.        break;
  504.  
  505.     case PHONEERR_INVALBUTTONMODE:
  506.        MessageBox (hWnd, "Invalid Button Mode.", "", MB_OK);
  507.        break;
  508.  
  509.     case PHONEERR_INVALBUTTONSTATE:
  510.        MessageBox (hWnd, "Invalid Button State", "", MB_OK);
  511.        break;
  512.  
  513.     case PHONEERR_INUSE:
  514.        MessageBox (hWnd, "Phone in Use.", "", MB_OK);
  515.        break;
  516.     
  517.     case PHONEERR_INVALHOOKSWITCHDEV:
  518.        MessageBox (hWnd, "Invalid Hookswitch Device.", "", MB_OK);
  519.        break;
  520.  
  521.     case PHONEERR_INVALHOOKSWITCHMODE:
  522.        MessageBox (hWnd, "Invalid Hookswitch Device Mode.", "", MB_OK);
  523.        break;
  524.  
  525.     case PHONEERR_INVALLAMPMODE:
  526.        MessageBox (hWnd, "Invalid Lamp Mode.", "", MB_OK);
  527.        break;
  528.      
  529.     case PHONEERR_INCOMPATIBLEEXTVERSION:
  530.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  531.        break;
  532.     case PHONEERR_NOMEM:
  533.        MessageBox (hWnd, "No memory","", MB_OK);
  534.        break;
  535.     case PHONEERR_NODRIVER:
  536.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  537.        break;
  538.     case PHONEERR_RESOURCEUNAVAIL:
  539.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  540.        break;
  541.     case PHONEERR_ALLOCATED:
  542.        MessageBox (hWnd, "Allocation error", "", MB_OK);
  543.        break;
  544.     case PHONEERR_INVALDATAID:
  545.        MessageBox (hWnd, "The data ID is out of range.", "", MB_OK);
  546.        break;
  547.     case PHONEERR_INVALDEVICECLASS:
  548.        MessageBox (hWnd, "The device class was invalid.", "", MB_OK);
  549.        break;
  550.     case PHONEERR_INVALPOINTER:
  551.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  552.                    "", MB_OK);
  553.        break;
  554.     case PHONEERR_OPERATIONFAILED:
  555.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  556.        break;
  557.     case PHONEERR_INVALPHONEHANDLE:
  558.        MessageBox (hWnd, "Invalid phone handle", "", MB_OK);
  559.        break;
  560.     case PHONEERR_INVALPHONESTATE :
  561.        MessageBox (hWnd, "Invalid call state for this function.", "", MB_OK);
  562.        break;
  563.     case PHONEERR_INVALPRIVILEGE:
  564.        MessageBox (hWnd, "Invalid privilege for this function.", "", MB_OK);
  565.        break;
  566.     case PHONEERR_NODEVICE:
  567.        MessageBox (hWnd, "No associated device for given class",
  568.                    "", MB_OK);
  569.        break;
  570.     case PHONEERR_OPERATIONUNAVAIL:
  571.        MessageBox (hWnd, "The operation is unavailable",
  572.                    "", MB_OK);
  573.        break;
  574.     case PHONEERR_INVALPARAM:
  575.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  576.        break; 
  577.  
  578.     case PHONEERR_INVALRINGMODE:
  579.             MessageBox(hWnd, "Invalid Ring Mode", "", MB_OK);
  580.        break; 
  581.  
  582.     }
  583.     
  584.              
  585. }
  586.  
  587. LRESULT CALLBACK About( HWND hDlg,           
  588.                         UINT message,        
  589.                         WPARAM wParam,       
  590.                         LPARAM lParam)
  591. {
  592.    switch (message) 
  593.    {
  594.        case WM_INITDIALOG: 
  595.                return (TRUE);
  596.  
  597.        case WM_COMMAND:                              
  598.                if (   LOWORD(wParam) == IDOK         
  599.                    || LOWORD(wParam) == IDCANCEL)    
  600.                {
  601.                        EndDialog(hDlg, TRUE);        
  602.                        return (TRUE);
  603.                }
  604.                break;
  605.    }
  606.  
  607.    return (FALSE); 
  608. }
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.